import React from 'react';
export default class Parent extends React.Component {
  state = {
    money: 1000,
  };

  handleMakeMoney = () => {
    this.setState({
      money: 1000 + this.state.money,
    });
  };

  render() {
    return (
      <div>
        <button onClick={this.handleMakeMoney}>
          爸爸开始赚钱了 - {this.state.money}
        </button>
        <Child money={this.state.money}></Child>
      </div>
    );
  }
}

class Child extends React.Component {
  render() {
    // console.log('this.props -----> ', this.props);
    const { money } = this.props;
    return (
      <div>
        <h1>爸爸给我钱了：{money} </h1>
      </div>
    );
  }
}
